﻿Imports DTO
Imports BUS

Public Class fmdanmucphong
   
    Private Sub fmdanmucphong_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As List(Of PhongDto)
        Dim bus As New PhongBus()
        ds = bus.LayDanhSach()
        dgvDanhSachPhong.Rows.Clear()
        For i As Integer = 0 To ds.Count - 1
            dgvDanhSachPhong.Rows.Add(ds(i).MaPhong, ds(i).TenPhong, ds(i).MaLoaiPhong, ds(i).TinhTrang, ds(i).GhiChu)
        Next


        cbbLoaiPhong.DataSource = bus.TryVan("SELECT MaLoaiPhong FROM LOAIPHONG")
        cbbLoaiPhong.DisplayMember = "MaLoaiPhong"
        cbbLoaiPhong.ValueMember = "MaLoaiPhong"
    End Sub

   
    Private Sub btnthoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoat.Click
        Close()
    End Sub

    Private Sub btntiepnhan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntiepnhan.Click
        If (txttenphong.Text = "") Then
            MessageBox.Show("Bạn chưa nhập tên Phong ", "Chú ý !")
        End If

        Dim pDTO As New PhongDto()
        pDTO.TenPhong = txttenphong.Text.Trim()
        pDTO.GhiChu = txtghichu.Text.Trim()
        pDTO.TinhTrang = cbbtinhtrang.Text()
        pDTO.MaLoaiPhong = Integer.Parse(cbbLoaiPhong.Text())
        'goi BUS
        ' Dim kq As Integer
        Dim bus As New PhongBus()
        bus.ThemPhong(pDTO)
        fmdanmucphong_Load(sender, e)
    End Sub

    Private Sub btnreset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreset.Click

    End Sub
End Class